package com.dreamer.service.pyramid;

import com.dreamer.domain.pyramid.PyramidUser;
import com.dreamer.domain.pyramid.PyramidUserVo;
import com.dreamer.domain.pyramid.UserBankCard;
import com.dreamer.repository.pyramid.PyramidUserDAO;
import com.dreamer.repository.pyramid.UserBankCardDAO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ps.mx.otter.utils.SearchParameter;

import java.util.List;

@Service
public class UserBankCardHandler {

    @Autowired
    private UserBankCardDAO userBankCardDAO;

    @Transactional
    public UserBankCard saveOrupdate(UserBankCard userBankCard){
        UserBankCard instance = userBankCardDAO.merge(userBankCard);
        LOG.debug("新增活动成功"+instance);
        return userBankCard;
    }

    @Transactional
    public void remove(UserBankCard pyramidUser) {
        userBankCardDAO.delete(pyramidUser);
        LOG.debug("删除活动成功");
    }

    private final Logger LOG = LoggerFactory.getLogger(getClass());

    public UserBankCard findById(Integer integer) {
        return  userBankCardDAO.findById(integer);
    }

    public List<UserBankCard> searchAllByPage(SearchParameter<UserBankCard> parameter) {
        return userBankCardDAO.searchAllByPage(parameter);
    }

    public List<UserBankCard> findAll(){
        return userBankCardDAO.findAll();
    }

    public List<UserBankCard> findByUserId(Integer userId){
        return userBankCardDAO.findByUserId(userId);
    }

}
